package com.zyx.wanshu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyx.wanshu.entity.UserRole;
import com.zyx.wanshu.mapper.UserRoleMapper;
import com.zyx.wanshu.service.IUserRoleService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * @author zyx
 * @since 2022/7/15 22:24
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {

    @Override
    public List<UserRole> queryList(UserRole userRole) {
        LambdaQueryWrapper<UserRole> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Objects.isNull(userRole.getUserId()), UserRole::getUserId, userRole.getUserId())
                .eq(Objects.isNull(userRole.getRoleId()), UserRole::getRoleId, userRole.getRoleId());
        return this.baseMapper.selectList(queryWrapper);
    }

}
